Skip to content

TOC-Turing Machine

  • Turing Machines are general purpose, meaning that they can take the encoding of a computation model and simulate the behavior.
  • Turing Machines are more powerful than modern computers. Whatever we can do on a computer, Turing Machines can do the same.
  • Turing Machines have the same computational power as λ - calculus. (By Alonzo Church) and recursion functions (by Kurt Godel).
  • Even Turing Machines are not ultimate. Those unsolvable problems are beyond the limit of computation.

Definition

A Turing Machine is a 7-tuple:

M=(Q,Σ,Γ,δ,q0,qaccept,qreject),

where Q,Σ,Γ are finite sets, and:

  1. Q is the set of states,
  2. Σ is the input alphabet (Σ),
  3. Γ is the tape alphabet (Γ and ΣΓ),
  4. δ:Q×ΓQ×Γ×{L,R} is the transition function,
  5. q0Q is the start state,
  6. qacceptQ is the accept state, and
  7. qrejectQ is the reject state, where qrejectqaccept.

A Turing Machine can be described as

  • a control unit, which a state machine;
  • an infinite tap;
  • the control unit can read and write on the tap;
  • the control unit can move left and right;
  • the control unit has special states for rejecting and accepting take immediate effect.

Example

Let B={s#ss{0,1}} and a Turing Machine M be described as follows to recognize B. M operates on input string w as follows:

  1. Read the input w onto the tape.

  2. Ensure that w has exactly one #, otherwise reject.

  3. Zig-zag across the tape to the corresponding positions on either side of # to check whether these positions contain the same symbol.

    • Cross out the symbols if they are the same; otherwise, reject.
  4. When all symbols to the left of # are crossed out, check the symbols to the right of #.

    • If all are crossed out, accept; otherwise, reject.

B={s#s|s{0,1}} is not context free.

Problem: Input: Given a string α in {0,1,#} Question: Is αB?

Algorithm:

  1. load α on to memory
  2. Check if α has only one #, reject if no
  3. Repeat until no unmarked symbol
    • Find the first unmarked symbol in first half
    • Go right, exceed find the first unmarked symbol in second half
    • mark s'
    • reject if ss
    • go left exceed find the first unmarked symbol in first half
  4. accept if no more in second half.

+ Formal Definition

The above example shows the basic features of a Turing Machine.

  • (Preprocessing) Read the input (over an alphabet Σ) onto the tape and move the head to the first symbol in the input.

  • Note: The preprocessing is trivial, tedious, and required by every Turing Machine (TM). Thus, this part of the TM is always omitted.

  • To cross out symbols, a set of tape symbols Γ has to be defined.

    • Γ also contains a blank symbol to show that a tape cell is empty.
    • ΣΓ.
  • q0Q is the start state.

  • qacceptQ is the accept state.

  • qrejectQ is the reject state, where qrejectqaccept.

  • The state machine has a transition function:

    δ:Q×ΓQ×Γ×{L,R}

    of the input:

    • A current state in Q, and
    • A tape symbol in Γ in the cell currently pointed to by the state machine.
  • And of the output:

    • The next state in Q,
    • The new tape symbol in Γ replacing the symbol in the current cell, and
    • Either L or R, the direction that the state machine is moving.

Computation on TMs

Accept A TM M accepts a string w if it halts on the input w at an accepting state.

Reject A TM M rejects a string w if it halts on the input w at a reject state.

If the transition function is only a partial function (some elements in the domain is undefined),

A TM M rejects a string w if

  • it halts on the input w at a reject state, or
  • it has no where to move in the middle of the process.

Using a partial transition function can omit the reject states. To make a partial function be total, we just artificially add those undefined transitions to a reject state.

Language

The language for TM are of two types.

A language L is recursive or Turing-decidable if there is a TM M such that

  • wL, M accepts w; and
  • wL, M rejects w.

We say M decides L.

A language L is recursively enumerable (or Turing-recognizable) if there is a TM M such that

  • wL,M accepts w; and
  • wL, M rejects w or M loops forever.

We say M recognizes L.

Side Effect

When a TM halts on an input,

  • the current state "accept" or "reject" is the output;
  • the content remains on its tape is the side effect.

A TM has a side effect if users need to read tape content to get the desired output. (Using only states of the TM is insufficient to express the output.)

If a TM has no side effect and is only used for checking its output, it is pure; otherwise, it is impure.